﻿using UnityEngine;
using System.Collections;

namespace UI
{
    public class UILuckEvent : MonoBehaviour
    {
        /// <summary>
        /// 伙伴祝福
        /// </summary>
        public void OnFriendBlessingPress()
        {
            if(StaticData.playerData.level < Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.FriendWishLevel)
            {
                BoxManager.CreatePopupTextBox(string.Format(TableTextBlo.GetText("levelTooLow"), Dict.DictDataManager.Instance.tableGameConfigureDao.currentData.FriendWishLevel));
                return;
            }
            PageManager.instance.OpenPage("PartnerMasterPage", "");
        }

        /// <summary>
        /// 关闭按钮
        /// </summary>
        public void OnClosedClick()
        {
            GetComponent<UILuck>().Close();
        }

        #region 上阵
        /// <summary>
        /// 上阵位置1
        /// </summary>
        public void InBattlePressPosOne()
        {
            OpenInBattlePage(1);
        }
        /// <summary>
        /// 上阵位置2
        /// </summary>
        public void InBattlePressPosTwo()
        {
            OpenInBattlePage(2);

        }
        /// <summary>
        /// 上阵位置3
        /// </summary>
        public void InBattlePressPosThree()
        {
            OpenInBattlePage(3);

        }
        /// <summary>
        /// 上阵位置4
        /// </summary>
        public void InBattlePressPosFour()
        {
            OpenInBattlePage(4);
        }
        
        protected void OnClickBattleIndex(int index)
        {
            HeroReplacePage page = (HeroReplacePage)PageManager.Instance.GetDictPage("HeroReplacePage");
            page.m_callback = delegate 
            {
                
            };
        }

        #endregion

        #region 左边助阵
        /// <summary>
        /// 左边助阵位置1
        /// </summary>
        public void LeftHelpBattlePressPosOne()
        {
            OpenHelpPage(1);
        }
        /// <summary>
        /// 左边助阵位置2
        /// </summary>
        public void LeftHelpBattlePressPosTwo()
        {
            OpenHelpPage(2);
        }
        /// <summary>
        /// 左边助阵位置3
        /// </summary>
        public void LeftHelpBattlePressPosThree()
        {
            OpenHelpPage(3);
        }
        #endregion

        #region 右边助阵
        /// <summary>
        /// 右边助阵位置1
        /// </summary>
        public void RightHelpBattlePressPosOne()
        {
            OpenHelpPage(4);
        }
        /// <summary>
        /// 右边助阵位置2
        /// </summary>
        public void RightHelpBattlePressPosTwo()
        {
            OpenHelpPage(5);
        }

        /// <summary>
        /// 右边助阵位置3
        /// </summary>
        public void RightHelpBattlePressPosThree()
        {
            OpenHelpPage(6);
        }
        #endregion
        
        protected void OpenHelpPage(int n)
        {
            string str = "array_help_pos" + n;
            if (CommonMethod.GetModuleOpen(str))
            {
                PageManager.Instance.OpenPage("HeroReplacePage", "index="+n+"&help=true");
            }
            else
            {
                string str0 = TableTextBlo.GetText("character_level_charge")+ Dict.DictModuleBlo.GetTableModule(str).openLev;
                BoxManager.CreatePopupTextBox(str0);
            }
        }
        
        protected void OpenInBattlePage(int n)
        {
            if (CommonMethod.GetModuleOpen("array_pos"+n))
            {
                PageManager.Instance.OpenPage("HeroReplacePage", "index="+n);
                OnClickBattleIndex(1);
            }
            else
            {
                string str = TableTextBlo.GetText("character_level_charge") + Dict.DictModuleBlo.GetTableModule("array_pos"+n).openLev;
                BoxManager.CreatePopupTextBox(str);
            }
        }
    }
}